<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><c:out value="${complainTypeName}"></c:out></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<style type="text/css">
   .text-left {
    color: #949494;
   }
   .box-body {
    		margin-top:7px;
    	}
    	.box-body{
        margin-bottom:-20px;
        }
</style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><c:out value="${complainTypeName}"></c:out></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
             <li class="active">申投诉管理</li>
        </ol>
    </section>
    <section class="content">
      <form id="form" class="form-horizontal" action="${ctx}/sysComplainPro/saveData.html" method="post" enctype="multipart/form-data" >
        <div class=" box box-success">
            <!-- form start -->
            
                <div class="box-header with-border">
                       <h3 class="box-title">机构信息</h3>
                  </div>
                <div class="box-body">                                  
                 <div class="form-group form-group-xs">
                <input id="hospShowId" name="hospShowId" type="hidden" value="<c:out value="${hospId}"></c:out>">
                        <label class="col-sm-2 text-right">名称：</label>
                         <div class="col-sm-2 text-left">
                        <c:out value="${hospName}"></c:out>
                        </div>
                    </div>
                </div>    
                    
                <div class="box-header with-border">
                       <h3 class="box-title"><c:out value="${complainTypeName}"></c:out>人信息</h3>
                </div>  
                <div class="box-body">   
                 <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>真实姓名：</label>
                        <div class="col-sm-3 text-left">
                            <input class=" form-control" placeholder="姓名" id="name" name="name" type="text" maxlength="4">
                        </div>
                        <label class="col-sm-3 text-right"><span class="required">*</span>性&nbsp;&nbsp;别：</label>
                        <select class=" form-control" style="width:80px; " name="sex" id="sex" >
                        <option value="男">男</option>
                        <option value="女">女</option>
                        </select> 
                    </div>
                      <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>联系电话：</label>
                        <div class="col-sm-3 text-left">
                            <input class=" form-control" placeholder="联系电话" id="phoneNum" name="phoneNum" type="text" maxlength="11">
                        </div>
                        <label class="col-sm-3 text-right"><span class="required">*</span>电子邮箱：</label>
                        <div class="col-sm-3 text-left">
                            <input class=" form-control" placeholder="电子邮箱" id="email" name="email" type="text" maxlength="64">
                        </div>
                    </div>
                      <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>身份证号：</label>
                        <div class="col-sm-3 text-left">
                            <input class=" form-control" placeholder="身份证号码" id="idNum" name="idNum" type="text" maxlength="18">
                        </div>
                         <label class="col-sm-3 text-right"><span class="required">*</span>邮&nbsp;&nbsp;编：</label>
                        <div class="col-sm-3 text-left">
                            <input class=" form-control" placeholder="邮编" id="zipcode" name="zipcode" type="text" maxlength="10">
                        </div>
                    </div>
                      <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>通讯地址：</label>
                        <div class="col-sm-9 text-left">
                            <input class=" form-control" placeholder="通讯地址" id="address" name="address" type="text" maxlength="512">
                        </div>
                    </div>
                </div>
                    
                <div class="box-header with-border">
                       <h3 class="box-title"><c:out value="${complainTypeName}"></c:out>内容</h3>
                </div>  
                <div class="box-body">    
                 <input type="hidden" id="numberId" name="numberId" value="">
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><c:out value="${complainTypeName}"></c:out>标题：</label>
                        <div class="col-sm-9 text-left">
                            <input class=" form-control" placeholder="标题" id="complainTitle" name="complainTitle" type="text" maxlength="64">
                        </div>
                    </div>
                     <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><c:out value="${complainTypeName}"></c:out>内容：</label>
                        <div class="col-sm-9 text-left">
                            <textarea rows="5" cols="5" class=" form-control" name="complainContent" id="complainContent" maxlength="1200"></textarea> 
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label class="col-sm-4 text-right"><c:out value="${complainTypeName}"></c:out>相关项目&nbsp;：</label>
                        <div class="col-sm-5 text-left">
                            <input type="hidden" name="projId" id="projId" value="">
                             <input class=" form-control" readonly="readonly" placeholder="相关项目" disabled="disabled" id="projName" name="projName" type="text">
                        </div>
                        <div class="col-sm-2 text-left">
                            <a href="javascript:void(0)" onclick="selectproj();" class="btn btn-default btn-sm" >选择</a>
                        </div>
                         <div  id="projNameAdd1">
                        </div>
                   </div>
                       <div class="form-group form-group-xs">
                        <label class="col-sm-4 text-right"><i class="fa fa-plus" id="hospihidden0" style="color: blue;margin-right: 15px;" onclick="addDiv('hosp',0)"></i><c:out value="${complainTypeName}"></c:out>医疗机构&nbsp;：</label>
                        <div class="col-sm-5 text-left">
                            <input type="hidden" name="hospId" id="hospId" value="">
                             <input class=" form-control" readonly="readonly" placeholder="医疗机构" disabled="disabled" id="hospName" name="hospName" type="text">
                        </div>
                        <div class="col-sm-2 text-left">
                            <a href="javascript:void(0)" onclick="selecthosp();" class="btn btn-default btn-sm" >选择</a>
                        </div>
                        <div  id="hospNameAdd1">
                        </div>
                   </div>
                  
                  <div class="form-group form-group-xs">
                        <label class="col-sm-4 text-right"><i class="fa fa-plus" id="delcompihidden0" style="color: blue;margin-right: 15px;" onclick="addDiv('delcomp',0)"></i><c:out value="${complainTypeName}"></c:out>配送企业&nbsp;：</label>
                        <div class="col-sm-5 text-left">
                            <input type="hidden" name="delcompId" id="delcompId" value="">
                             <input class=" form-control" readonly="readonly" placeholder="配送企业" disabled="disabled" id="delcompName" name="delcompName" type="text">
                        </div>
                        <div class="col-sm-2 text-left">
                            <a href="javascript:void(0)" onclick="selectdelcomp();" class="btn btn-default btn-sm" >选择</a>
                        </div>
                        <div  id="delcompNameAdd1">
                        </div>
                   </div>
                  
                          <div class="form-group form-group-xs">
                        <label class="col-sm-4 text-right"><i class="fa fa-plus" id="compihidden0" style="color: blue;margin-right: 15px;" onclick="addDiv('comp',0)"></i><c:out value="${complainTypeName}"></c:out>生产企业&nbsp;：</label>
                        <div class="col-sm-5 text-left">
                            <input type="hidden" name="compId" id="compId" value="">
                             <input class=" form-control" readonly="readonly" placeholder="生产企业" disabled="disabled" id="compName" name="compName" type="text">
                        </div>
                        <div class="col-sm-2 text-left">
                            <a href="javascript:void(0)" onclick="selectcomp();" class="btn btn-default btn-sm" >选择</a>
                        </div>
                        <div  id="compNameAdd1">
                        </div>
                   </div>
                  
                        <div class="form-group form-group-xs">
                        <label class="col-sm-4 text-right"><i class="fa fa-plus"  id="drugihidden0" style="color: blue;margin-right: 15px;" onclick="addDiv('drug',0)"></i><c:out value="${complainTypeName}"></c:out>相关药品&nbsp;：</label>
                        <div class="col-sm-5 text-left">
                            <input type="hidden" name="drugId" id="drugId" value="">
                            <input class=" form-control" readonly="readonly" disabled="disabled" placeholder="药品" id="drugName" name="drugName" type="text">
                        </div>
                        <div class="col-sm-2 text-left">
                            <a href="javascript:void(0)" onclick="selectdrug();" class="btn btn-default btn-sm">选择</a>
                        </div>
                        <div id="drugNameAdd1"></div>
                   </div>
                   </div>
                   
                   <div class="box-header with-border" >
                       <h3 class="box-title">相关证明</h3>
                </div>  
                <div class="box-body"> 
         			 <div class="form-group form-group-xs">
      				   <label class="col-sm-4 text-right"><i class="fa fa-plus addFa"  id="licence0" style="color: blue;margin-right: 15px;" ></i><c:out value="${complainTypeName}"></c:out>附件&nbsp;：</label>
                        <div class="col-sm-4 text-left" id="imageName" >
                        	 <input type="text" class="form-control" id="attrName" name="attrName" placeholder="附件名称" >
                        </div>
                        <div class="col-sm-4 text-center"  >
                        	<input type="file"  accept="image/*" id="licences" name="licences" >
                        </div>
                     </div>
                     <div class="addLicenceDiv"></div>
                 </div>    
 
                 <div class="box-footer text-center">
                    <button type="button" onclick="save();" class="btn btn-success btn-sm">保&nbsp;存</button>
                     <a href="javascript:history.go(-1);" class="btn btn-danger btn-sm">返&nbsp;回</a>
                </div>
              
              	<input type="hidden" name="complainType" value="<c:out value="${complainType}"></c:out>" />
            
        </div>
        </form>
        <div id='coverdiv' style="Opacity:0.8;  position:fixed; left:0px; top:0px;width:100%;height:100%;"> </div>
        <div id='mydiv' style="border:0px solid #666666 ; padding:50px;text-align:center; position:absolute;background-image: url('${ctx }/lib/img/loading.gif'); background-repeat: no-repeat;">
</div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script src="${ctx}/lib/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
	
	var cover =mydiv= null;
	window.onload = function() {
	  cover=document.getElementById('coverdiv');
	  cover.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
	  cover.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px"
	  cover.style.display = "none";
	 
	  mydiv = document.getElementById('mydiv');
	  with (mydiv){
	    style.width = document.documentElement.scrollHeight/2+"px";
	    style.height = document.documentElement.scrollHeight/2+"px";
	    style.left = (document.documentElement.scrollWidth - mydiv.offsetWidth)/2+"px";
	    style.top = (document.documentElement.scrollHeight - mydiv.offsetHeight)/2+"px";
	 
	    style.display = "none";
	  }
	};
	$(function(){
		$(document).on("click",".addFa",function(){
		   var attrName = $(this).closest('.form-group-xs').find('#attrName').val();
		   var licences = $(this).closest('label').siblings('.col-sm-4').find('#licences').val();
		  if("" == $.trim(attrName) || null == $.trim(attrName)){
			   $.HN.message.alert('请先输入要${complainTypeName}的附件名称！', '提示信息', 'error');
	           return;
		   }
		   if("" == $.trim(licences) || null == $.trim(licences)){
			   $.HN.message.alert('请先上传要${complainTypeName}的附件！', '提示信息', 'error');
	           return;
		   } 
		   $(this).attr({ "class": "fa fa-times deleteFa"});
		   $(".addLicenceDiv").append("<div class='form-group form-group-xs'><label class='col-sm-4 text-right'><i class='fa fa-plus addFa' style='color: blue;margin-right: 15px;' ></i>${complainTypeName}附件&nbsp;：</label>"
		   +"<div class='col-sm-2 text-left' ><input type='text' class='form-control' id='attrName' name='attrName' placeholder='附件名称' ></div>"
		   +"<div class='col-sm-4 text-left' ><input type='file'  accept='image/*' id='licences' name='licences' ></div></div>");
		})
		$(document).on("click",".deleteFa",function(){
			   $(this).attr({ "class": "fa fa-plus addFa"});
			   $(this).closest('.form-group-xs').remove();
		})
	})
	
   
   function removeDiv(strName){
	   num = num -1;
	   if(strName == "proj"){
		   for(num;num <= numberproj;num++){
			   $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
			   $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
			   if(num == numberproj){
				   $("#"+strName+"ihidden"+(num-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(num+1)+"')" });
				   $("#"+strName+"NameAdd"+num).html("");
			   }
		   } 
		   numberproj -= 1;
	   }
   }   
	   var numberproj=1;
	   var numberhosp=1;
	   var numberDelcomp=1;//配送企业
	   var numbercomp=1;//生产企业
	   var numberdrug=1;
	 function save(){
		 var orgId = $.trim($("#hospShowId").val());
		 var orgType = $.trim($("#orgType").val());
		 var name = $.trim($("#name").val());
		 var sex = $.trim($("#sex").val());
		 var phoneNum = $.trim($("#phoneNum").val());
		 var email = $.trim($("#email").val());
		 var idNum = $.trim($("#idNum").val());
		 var zipcode = $.trim($("#zipcode").val());
		 var address = $.trim($("#address").val());
 		 if(name == "" || null == name){
			$.alert("请填写真实姓名！","warn");
   		     return;
		 }
		if(phoneNum == "" || null == phoneNum){
			$.alert("请填写联系电话！","warn");
   		     return;
		 }else if (!/^(\d+[-]\d+)|(\d+)$/.test(phoneNum)) {
				$.alert("联系电话格式输入错误！请重新输入！",  "warn");
				return ;
			}
		if(email == "" || null == email){
			$.alert("请填写邮箱！","warn");
   		     return;
		 } else if (!/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(email)) {
				$.alert("电子邮箱格式错误！请重新输入！", "warn");
				return;
			}
		if(idNum == "" || null == idNum){
			$.alert("请填写身份证号码！","warn");
   		     return;
		 }else if (!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/.test(idNum)) {
				$.alert("身份证号格式错误！请重新输入！",  "warn");
				return;
			}
		if(zipcode == "" || null == zipcode){
			$.alert("请填写邮编！","warn");
   		     return;
		 }else if (!/^\d+[a-zA-Z0-9]$/.test(zipcode)) {
				$.alert("邮编只能由数字组成！",  "warn");
				return;
			}
		if(address == "" || null == address){
			$.alert("请填写通信地址！","warn");
   		     return;
		 } 
		 var complainTitle = $.trim($("#complainTitle").val());
    	 if (complainTitle == ""){
    		 $.alert("标题不能为空！","warn");
    		 return;
    	 }
    	 var complainContent = $.trim($("#complainContent").val());
    	 if (complainContent == ""){
    		 $.alert("输入内容不能为空！","warn");
    		 return;
    	 }
    	 var attrName = $.trim($("#attrName").val());
    	 var licences = $("#licences").val();
    	 if(licences == "" || null == licences){
    		 $.alert("请上传相关证明！","warn");
    		 return;
    	 }else{
    		 if(attrName == "" || null == attrName){
    			 $.alert("请命名文件名称！","warn");
        		 return;
    		 }
    	 }
   	  $.HN.message.confirm('确定要保存吗？', '', '').on(function (e) {
             if (e) {
            	 mydiv.style.display =cover.style.display = '';
                 $("#form").ajaxSubmit({
                     dataType : "json",
                     success : function(result) {
                    	 mydiv.style.display =cover.style.display = 'none';
                         if (result.success) {
                        	$.HN.message.alert("操作成功！", "消息", "success");
                        	window.setTimeout("document.location.href='${ctx}/sysComplainMed/toSysComplainListJsp.html'",500); 
                         } else {
                             $.HN.message.alert(result.msg || "操作失败！",  "消息", "error");
                         }
                        
                     }
                 });
             }
         });
   	
   }
   function back(){
   	window.location.href="${ctx}/sysComplainMed/toSysComplainListJsp.html";
   }
   //项目选择
   function selectproj(obj,strProjId){
	   if("" != obj && null != obj && strProjId != "" && null != strProjId){
			  if(obj <= numberproj){
				  var objNum = obj;
				  for(objNum;objNum<=numberproj;objNum++){
					   strProjId += ($("#projId"+objNum).val()+",");
				   }
			  }
		   $.HN.dialog.opendialog(1,"相关项目列表","${ctx}/sysComplain/toProjListJsp.html?numberId="+obj+"&projId="+strProjId,"800px","400px",operProjResult);
	   }else{
		   $.HN.dialog.opendialog(1,"相关项目列表","${ctx}/sysComplain/toProjListJsp.html","800px","400px",operProjResult);
	   }
	  
   }
   	
   function operProjResult(val){
   	var strs = new Array();
       strs = val.split("|$");
       var numId = strs[2];
       if("" != numId && null != numId){
    		if (val.length>0) {
				$("#projId"+numId).val(strs[0]);
				$("#projName"+numId).val(strs[1]);
			}
       }else{
    		if (val.length>0) {
				$("#projId").val(strs[0]);
				$("#projName").val(strs[1]);
			}
       }
       
   	}
   
 //医疗机构选择
   function selecthosp(obj,strHospId){
	   if("" != obj && null != obj && strHospId != "" && null != strHospId){
		   if(obj <= numberhosp){
				  var objNum = obj;
				  for(objNum;objNum<=numberhosp;objNum++){
					  strHospId += ($("#hospId"+objNum).val()+",");
				   }
			  }
		   $.HN.dialog.opendialog(1,"医疗机构列表","${ctx}/sysComplain/toHospListJsp.html?numberId="+obj+"&hospId="+strHospId,"800px","400px",operHospResult);
	   }else{
		   $.HN.dialog.opendialog(1,"医疗机构列表","${ctx}/sysComplain/toHospListJsp.html","800px","400px",operHospResult);
	   }
	   
   }
   	
   function operHospResult(val){
   	var strs = new Array();
       strs = val.split("|$");
       	var numId = strs[2];
        if("" != numId && null != numId){
     		if (val.length>0) {
 				$("#hospId"+numId).val(strs[0]);
 				$("#hospName"+numId).val(strs[1]);
 			}
        }else{
     		if (val.length>0) {
     			$("#hospId").val(strs[0]);
				$("#hospName").val(strs[1]);
 			}
        }
   	}
   
 //配送企业选择
   function selectdelcomp(obj,strCompId){
	   if("" != obj && null != obj && strCompId != "" && null != strCompId){
		   if(obj <= numberDelcomp){
				  var objNum = obj;
				  for(objNum;objNum<=numberDelcomp;objNum++){
					  strCompId += ($("#delcompId"+objNum).val()+",");
				   }
			  }
		   $.HN.dialog.opendialog(1,"配送企业列表","${ctx}/sysComplain/toDelcompListJsp.html?numberId="+obj+"&delcompId="+strCompId,"800px","400px",operDelCompResult);
	   }else{
		   $.HN.dialog.opendialog(1,"配送企业列表","${ctx}/sysComplain/toDelcompListJsp.html","800px","400px",operDelCompResult);
	   }
   }
   	
   function operDelCompResult(val){
   	var strs = new Array();
       strs = val.split("|$");
       var numId = strs[2];
       	if("" != numId && null != numId){
     		if (val.length>0) {
 				$("#delcompId"+numId).val(strs[0]);
 				$("#delcompName"+numId).val(strs[1]);
 			}
        }else{
     		if (val.length>0) {
     			$("#delcompId").val(strs[0]);
				$("#delcompName").val(strs[1]);
 			}
        }
   	}
   
   //生产企业选择
  function selectcomp(obj,strCompId){
	  strCompId += (","+$("#prodCompId").val()+",");
	   if("" != obj && null != obj && strCompId != "" && null != strCompId){
		   if(obj <= numbercomp){
				  var objNum = obj;
				  for(objNum;objNum<=numbercomp;objNum++){
					  strCompId += ($("#compId"+objNum).val()+",");
				   }
			  }
		   $.HN.dialog.opendialog(1,"生产企业列表","${ctx}/sysComplain/toProdcompListJsp.html?numberId="+obj+"&prodcompId="+strCompId,"800px","400px",operCompResult);
	   }else{
		   $.HN.dialog.opendialog(1,"生产企业列表","${ctx}/sysComplain/toProdcompListJsp.html?prodcompId="+strCompId,"800px","400px",operCompResult);
	   }
	  
   }
   	
   function operCompResult(val){
   	var strs = new Array();
       strs = val.split("|$");
       var numId = strs[2];
       	if("" != numId && null != numId){
     		if (val.length>0) {
 				$("#compId"+numId).val(strs[0]);
 				$("#compName"+numId).val(strs[1]);
 			}
        }else{
     		if (val.length>0) {
     			$("#compId").val(strs[0]);
				$("#compName").val(strs[1]);
 			}
        }
   	}
   
 //选择药品
   function selectdrug(obj,strDrugId){
	   if("" != obj && null != obj && strDrugId != "" && null != strDrugId){
		   if(obj <= numberdrug){
				  var objNum = obj;
				  for(objNum;objNum<=numberdrug;objNum++){
					  strDrugId += ($("#drugId"+objNum).val()+",");
				   }
			  }
		   $.HN.dialog.opendialog(1,"药品列表","${ctx}/sysComplain/toProdListJsp.html?numberId="+obj+"&prodId="+strDrugId,"800px","400px",operDrugResult);
	   }else{
		   $.HN.dialog.opendialog(1,"药品列表","${ctx}/sysComplain/toProdListJsp.html","800px","400px",operDrugResult);
	   }
	   
   }
   	
   function operDrugResult(val){
   	var strs = new Array();
       strs = val.split("|$");
       var numId = strs[2];
       	if("" != numId && null != numId){
     		if (val.length>0) {
 				$("#drugId"+numId).val(strs[0]);
 				$("#drugName"+numId).val(strs[1]);
 			}
        }else{
     		if (val.length>0) {
     			$("#drugId").val(strs[0]);
				$("#drugName").val(strs[1]);
 			}
        }
   	}
 
   function gridSerch() {
	   	var compCode = $("#compCode").val();
	   	var compName = $("#compName").val();
			$("#gridlist1").jqGrid('setGridParam',{  
		        datatype:'json',
		        postData:{"compCode":compCode,
		        		"compName":compName}
		    }).trigger("reloadGrid"); //重新载入  
		}
   
	   function addDiv(strName,vidNum){
		   if(vidNum == 0){
			   vidNum = "";
		   }	
		   var name = "";
		   var number = 0;
		   var strId = "";
		   if(strName == "proj"){
			   if("" == $.trim($("#projId"+vidNum).val()) || null == $.trim($("#projId"+vidNum).val())){
				   $.HN.message.alert('请先选择要${complainTypeName}的项目！', '提示信息', 'error');
		           return;
			   }
			   numberproj += 1;
			   name = "相关项目"
			   number = numberproj;
			   if(numberproj > 1){
				   for(var i=1;i<numberproj;i++){
					   if(i == 1){
						   strId = $.trim($("#projId").val());
					   }else{
						   strId =strId + "," + $.trim($("#projId"+(i-1)).val());
					   }
				   }
			   }
		   }
	       if(strName == "drug"){
	    	   if("" == $.trim($("#drugId"+vidNum).val()) || null == $.trim($("#drugId"+vidNum).val())){
				   $.HN.message.alert('请先选择要${complainTypeName}的药品！', '提示信息', 'error');
		           return;
			   }
	    	   name = "相关药品"
	    	   numberdrug += 1;
			   number = numberdrug;
			   if(numberdrug > 1){
				   for(var i=1;i<numberdrug;i++){
					   if(i == 1){
						   strId = $.trim($("#drugId").val());
					   }else{
						   strId =strId + "," + $.trim($("#drugId"+(i-1)).val());
					   }
				   }
			   }
	       }
	       if(strName == "hosp"){
	    	   if("" == $.trim($("#hospId"+vidNum).val()) || null == $.trim($("#hospId"+vidNum).val())){
				   $.HN.message.alert('请先选择要${complainTypeName}的医疗机构！', '提示信息', 'error');
		           return;
			   }
	    	   name = "医疗机构"
	    	   numberhosp += 1;
			   number = numberhosp;
			   if(numberhosp > 1){
				   for(var i=1;i<numberhosp;i++){
					   if(i == 1){
						   strId = $.trim($("#hospId").val());
					   }else{
						   strId =strId + "," + $.trim($("#hospId"+(i-1)).val());
					   }
				   }
			   }
	       }
	       
	       if(strName == "delcomp"){
	    	   if("" == $.trim($("#delcompId"+vidNum).val()) || null == $.trim($("#delcompId"+vidNum).val())){
				   $.HN.message.alert('请先选择要${complainTypeName}的配送企业！', '提示信息', 'error');
		           return;
			   }
	    	   name = "配送企业"
	    	   numberDelcomp += 1;
			   number = numberDelcomp;
			   if(numberDelcomp > 1){
				   for(var i=1;i<numberDelcomp;i++){
					   if(i == 1){
						   strId = $.trim($("#delcompId").val());
					   }else{
						   strId =strId + "," + $.trim($("#delcompId"+(i-1)).val());
					   }
				   }
			   }
	       }
	       
	       if(strName == "comp"){
	    	   if("" == $.trim($("#compId"+vidNum).val()) || null == $.trim($("#compId"+vidNum).val())){
				   $.HN.message.alert('请先选择要${complainTypeName}的生产企业！', '提示信息', 'error');
		           return;
			   }
	    	   name = "生产企业"
	    	   numbercomp += 1;
			   number = numbercomp;
			   if(numbercomp > 1){
				   for(var i=1;i<numbercomp;i++){
					   if(i == 1){
						   strId = $.trim($("#compId").val());
					   }else{
						   strId =strId + "," + $.trim($("#compId"+(i-1)).val());
					   }
				   }
			   }
	       }
	       $("#"+strName+"ihidden"+(number-2)).attr({ "class": "fa fa-times", "onclick": "removeDiv('"+strName+"',"+(number-1)+")" });
		   $("#"+strName+"NameAdd"+(number-1)).html("<br></br><label class=\"col-sm-4 text-right\"><i class=\"fa\ fa-plus\" id=\""+strName+"ihidden"+(number-1)+"\" style=\"color: blue;margin-right: 15px;\"  onclick=\"addDiv('"+strName+"','"+(number-1)+"')\"></i>${complainTypeName}"+name+""+(number-1)+"：</label><div class=\"col-sm-4 text-left\">"
           +"<input type=\"hidden\" name=\""+strName+"Id\" id=\""+strName+"Id"+(number-1)+"\" value=\"\">"
           +"<input class=\" form-control\" disabled=\"disabled\" readonly=\"readonly\" placeholder=\""+name+""+(number-1)+"\" id=\""+strName+"Name"+(number-1)+"\" name=\""+strName+"Name\" type=\"text\">"
           +"</div><div class=\"col-sm-2 text-left\">"
           +"<div class=\"col-sm-2 text-left\"><a href=\"javascript:void(0)\" onclick=\"select"+strName+"('"+(number-1)+"','"+strId+",');\" class=\"btn btn-default btn-sm\" >选择</a></div></div>"
           +" <div  id=\""+strName+"NameAdd"+number+"\"></div>"
		   );
	   }
	   
	   function removeDiv(strName,num){
		   num = num -1;
		   if(strName == "proj"){
			   for(num;num <= numberproj;num++){
				   $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
				   $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
				   if(num == numberproj){
					   $("#"+strName+"ihidden"+(num-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(num+1)+"')" });
					   $("#"+strName+"NameAdd"+num).html("");
				   }
			   } 
			   numberproj -= 1;
		   }
		   if(strName == "hosp"){
			   for(num;num <= numberhosp;num++){
				   if(num == 0){
					  $("#"+strName+"Id").val($("#"+strName+"Id"+(num+1)).val());
					  $("#"+strName+"Name").val($("#"+strName+"Name"+(num+1)).val());
				   }else{
				      $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
				      $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
				      if(num == numberhosp){
					  $("#"+strName+"NameAdd"+(num-1)).empty();
				      }
				   }
			   } 
			  
			   numberhosp -= 1;
			   $("#"+strName+"ihidden"+(numberhosp-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(numberhosp-1)+"')" });
		   }
		   
		   if(strName == "delcomp"){
			   for(num;num <= numberDelcomp;num++){
				   if(num == 0){
					   $("#"+strName+"Id").val($("#"+strName+"Id"+(num+1)).val());
					   $("#"+strName+"Name").val($("#"+strName+"Name"+(num+1)).val());
				   }else{
				      $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
				      $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
				      if(num == numberDelcomp){
					    $("#"+strName+"NameAdd"+(num-1)).empty();
				      }
				   }
			   } 
			   numberDelcomp -= 1;
			   $("#"+strName+"ihidden"+(numberDelcomp-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(numberDelcomp-1)+"')" });
		   }
		   if(strName == "comp"){
			   for(num;num <= numbercomp;num++){
				   if(num == 0){
					   $("#"+strName+"Id").val($("#"+strName+"Id"+(num+1)).val());
					   $("#"+strName+"Name").val($("#"+strName+"Name"+(num+1)).val());
				   }else{
				      $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
				      $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
				      if(num == numbercomp){
					    $("#"+strName+"NameAdd"+(num-1)).empty();
				      }
				   }
			   } 
			   numbercomp -= 1;
			   $("#"+strName+"ihidden"+(numbercomp-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(numbercomp-1)+"')" });
		   }
		   if(strName == "drug"){
			   for(num;num <= numberdrug;num++){
				   if(num == 0){
					   $("#"+strName+"Id").val($("#"+strName+"Id"+(num+1)).val());
					   $("#"+strName+"Name").val($("#"+strName+"Name"+(num+1)).val());
				   }else{
				      $("#"+strName+"Id"+num).val($("#"+strName+"Id"+(num+1)).val());
				      $("#"+strName+"Name"+num).val($("#"+strName+"Name"+(num+1)).val());
				      if(num == numberdrug){
					    $("#"+strName+"NameAdd"+(num-1)).empty();
				      }
				   }
			   } 
			   numberdrug -= 1;
			   $("#"+strName+"ihidden"+(numberdrug-1)).attr({ "class": "fa fa-plus", "onclick": "addDiv('"+strName+"','"+(numberdrug-1)+"')" });
		   }
		   
	   }
	   
	</script>
</body>
</html>